<template>
  <div class="head">
    <div style="display: flex;width: 100%;">
      <div class="title">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item class="text" label="运单编号">
            <el-input v-model="form.transportCodes" rows="4" class="input" placeholder="请输入运单号" type="textarea" />
          </el-form-item>
        </el-form>
      </div>
      <div style="margin-left: 40px;">
        <div class="title1" style="display: flex;flex-wrap: wrap;justify-content: space-between;">
          <el-form ref="form" style="display: flex;flex-wrap: wrap;justify-content: space-between;width: 1430px;" :model="form" label-width="80px">
            <div style="display: flex;flex-wrap: wrap;justify-content: space-between;width: 1100px;">
              <el-form-item class="text" label="收付类型">
                <el-select v-model="form.collectPayType" class="input" placeholder="请选择">
                  <el-option label="向寄件方收" value="1" />
                  <el-option label="向派件方付" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="费用小类">
                <el-select v-model="feeSmall" class="input" placeholder="请选择">
                  <el-option v-for="item in fyxl" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="网点名称">
                <el-select v-model="form.networkNameId" class="input" :disabled="true" placeholder="辽宁盘锦公司">
                  <el-option label="辽宁盘锦公司" value="1" />
                </el-select>
              </el-form-item>
            </div>
            <div>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
                <elbutton :obj="form" @dj="khClear" />
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="title1">
          <el-form ref="form" style="display: flex;justify-content: space-between;flex-wrap: wrap;width: 1300px;" :model="form">
            <div style="display: flex;flex-wrap: wrap;">
              <el-form-item class="text" style="display: flex;" label="承包区名称">
                <el-select v-model="form.sentNetworkNameId" class="input" placeholder="请选择">
                  <el-option v-for="item in ShowCoverAreaLit" :key="item.id" :label="item.networkName" :value="item.networkName" />
                </el-select>
              </el-form-item>
              <el-form-item style="display: flex;margin-left: 40px;" class="text" label="日期">
                <el-date-picker v-model="form.value1" class="input1" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" @change="changeTime" />
              </el-form-item>
            </div>
          </el-form>
        </div>
      </div>
    </div>
    <div class="line" />
    <div class="title3">
      <div class="text">说明：4月1日起该结算明细查询请至账单中心-网点总部对账查询</div>
      <div>
        <el-form>
          <el-form-item>
            <el-button class="bt" @click="onSubmit"><i class="el-icon-upload2" />导出</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <elltable :loading="loading" :data="tableData" :th="th" :n="5">
      <template v-slot:before-columns>
        <el-table-column v-if="tableData.length>0" label="序号" type="index" :index="table_index" width="100" fixed align="center" />

      </template>

    </elltable>
    <div style="display: flex;justify-content: space-between;margin-top: 51px;">
      <div class="title2" />
      <div class="block" style="display: flex; justify-content: flex-end">
        <pagination :current-page="current" :page-size="10" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </div>
  </div>
</template>

<script>
import { CostSmallKindApi, PaidSettlementApi, ShowCoverAreaApi } from '@/api/HqFinancePanel'

export default {

  components: {},
  data() {
    return {
      // 费用小类
      fyxl: [
        { value: '1', label: '全部' },
        { value: '2', label: '寄件预估' },
        { value: '3', label: '预估调整' },
        { value: '4', label: '退款' },
        { value: '5', label: '城市核心收费' },
        { value: '6', label: '冬季补贴收费' },
        { value: '7', label: '大货计重收费' },
        { value: '8', label: '违规重量罚款收' },
        { value: '9', label: '车线补贴收费' },
        { value: '10', label: '青海件收费' },
        { value: '11', label: '大货操作费收' },
        { value: '12', label: '乡镇补贴收' },
        { value: '13', label: '高峰期费用补贴收' },
        { value: '14', label: '纸质面单派费收' }

      ],
      loading: false,
      value1: '',
      form: {
        endTime: '',
        pageDate: {
          pageNum: 1,
          pageSize: 10
        },
        collectPayType: '',
        networkNameId: '辽宁盘锦公司',
        startTime: '',
        transportCodes: '',
        sentNetworkNameId: ''
      },
      feeSmall: '',
      tableData: [],
      CostSmallKindList: [], // 费用小类
      ShowCoverAreaLit: [], // 承包区列表
      current: 0, // 页数
      pages: 0, // 条数
      total: 0, // 总数
      th: []
    }
  },

  computed: {},

  created() {
    // this.CostSmallKind()
    this.ShowCoverArea()
  },

  methods: {
    handleSizeChange(val) {
      this.form.pageDate.pageSize = val
      this.onSubmit()
    },
    handleCurrentChange(val) {
      this.form.pageDate.pageNum = val
      this.onSubmit()
    },
    // 序号
    table_index(index) {
      return (this.form.pageDate.pageNum - 1) * this.form.pageDate.pageSize + index + 1
    },
    // 费用小类列表
    async CostSmallKind() {
      const res = await CostSmallKindApi()
      // console.log('费用小类', res)
      this.CostSmallKindList = res.data
    },
    // 承包区列表
    async ShowCoverArea() {
      const res = await ShowCoverAreaApi()
      this.ShowCoverAreaLit = res.data
    },
    // 选择时间
    changeTime(value) {
      this.form.startTime = value[0]
      this.form.endTime = value[1]
    },
    // 查询
    async onSubmit() {
      this.loading = true

      const res = await PaidSettlementApi(this.form)
      console.log('查询', res)
      this.loading = false

      if (res.code === 200) {
        this.tableData = res.data.list.data
        this.current = res.data.list.current
        this.total = res.data.list.total
        this.pages = res.data.list.pages
        this.th = res.data.fields
      } else {
        this.tableData = []
        this.current = 1
        this.total = 0
        this.pages = 10
      }
    },
    // 重置
    khClear(aaa) {
      this.form = aaa
      this.form.networkNameId = '辽宁盘锦公司'
    }
  }
}
</script>
<style
  scoped
  lang="scss"
>
.title {
  .input {
    width: 286px;
    // height: 88px;
    background: #ffffff;
    border: 1px solid #b4b4b4;
    border-radius: 4px;
  }
}

.head {
  padding: 30px;
}

.title {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}

.line {
  height: 1px;
  background: #d8d8d8;
  border-radius: 1px;
  margin-top: 0px;
  margin-bottom: 33px;
}

.title1 {
  .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;

    // margin-left: 52px;
    .input {
      width: 286px;
      height: 36px;
      background: #ffffff;
      // border: 1px solid #B4B4B4;
      border-radius: 4px;
    }

    .input1 {
      width: 650px;
      height: 36px;
      background: #ffffff;
      border: 1px solid #b4b4b4;
      border-radius: 4px;
    }
  }
}

.title2 {
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}

.title3 {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;

  .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ee3000;
  }

  .bt {
    width: 98px;
    height: 36px;
    background: #ffffff;
    border: 1px solid #b4b4b4;
    border-radius: 4px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
  }

  .bt:hover {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
  }
}
</style>
